package com.first.group.oldhouse.service.impl;

import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.first.group.common.utils.PageUtils;
import com.first.group.common.utils.Query;

import com.first.group.oldhouse.dao.OldHouseImgDao;
import com.first.group.oldhouse.entity.OldHouseImgEntity;
import com.first.group.oldhouse.service.OldHouseImgService;


@Service("oldHouseImgService")
public class OldHouseImgServiceImpl extends ServiceImpl<OldHouseImgDao, OldHouseImgEntity> implements OldHouseImgService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<OldHouseImgEntity> page = this.page(
                new Query<OldHouseImgEntity>().getPage(params),
                new QueryWrapper<OldHouseImgEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public void saveImages(Long oldHouseId, List<String> fileList) {
        //添加图片
        for (String s : fileList) {
            OldHouseImgEntity oldHouseImgEntity = new OldHouseImgEntity();
            oldHouseImgEntity.setOldHouseId(oldHouseId);
            oldHouseImgEntity.setOldImgUrl(s);
            baseMapper.insert(oldHouseImgEntity);
        }
    }

}